package com.jerei.store.config;


import com.jerei.store.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        List<String> exclude=new ArrayList<>();
        exclude.add("/user/login");
        exclude.add("/user/auto");
        exclude.add("/user/register");
        exclude.add("/web/login.html");
        exclude.add("/web/register.html");
        exclude.add("/bootstrap3/**");
        exclude.add("/css/**");
        exclude.add("/images/**");
        exclude.add("/js/**");

        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns(exclude);
    }
}
